/**
 * Copyright (C) 2009 Lazaro Brito
 *
 * This file is part of jIRC.
 * 
 * jIRC is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * jIRC is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with jIRC.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package org.lazaro.jirc.misc;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

/**
 * @author Lazaro Brito
 *
 */
public class Utils {
	private Utils() { }

	private static String ip = null;

	public static String getExternalIP() {
		if(ip == null) {
			try {
				ip = new BufferedReader(new InputStreamReader((new URL("http://whatismyip.com/automation/n09230945.asp")).openStream())).readLine();
			} catch(Exception e) {
				ip = "error";
			}
		}
		return ip;
	}
}